<script setup lang="ts">
import { reactive } from 'vue'
import { useRouter } from 'vue-router'
import { ElMessageBox } from 'element-plus'

const router = useRouter()
// do not use same name with ref
const form = reactive({
  name: '',
  region: '',
  date1: '',
  date2: '',
  delivery: false,
  type: [],
  resource: '',
  desc: ''
})

const onSubmit = () => {
  ElMessageBox.confirm('是否需要继续创建项目节点?', '提示', {
    confirmButtonText: '确认',
    cancelButtonText: '取消',
    type: 'success'
  }).then(() => {
    router.push('/create-milestone')
  })
}
</script>

<template>
  <div class="create-project">
    <el-text class="project-title" type="primary">创建项目</el-text>
    <el-form class="create-project-form" :model="form" label-width="auto">
      <el-form-item label="项目名称">
        <el-input v-model="form.name" placeholder="请输入项目名称" />
      </el-form-item>
      <el-form-item label="项目经理">
        <el-select v-model="form.region" placeholder="请选择项目经理">
          <el-option label="Zone one" value="shanghai" />
          <el-option label="Zone two" value="beijing" />
        </el-select>
      </el-form-item>
      <el-form-item label="产品经理">
        <el-select v-model="form.region" placeholder="请选择产品经理">
          <el-option label="Zone one" value="shanghai" />
          <el-option label="Zone two" value="beijing" />
        </el-select>
      </el-form-item>
      <el-form-item label="所属项目组">
        <el-select v-model="form.region" placeholder="请选择项目组">
          <el-option label="Zone one" value="shanghai" />
          <el-option label="Zone two" value="beijing" />
        </el-select>
      </el-form-item>
      <el-form-item label="项目描述">
        <el-input
          v-model="form.desc"
          type="textarea"
          :rows="8"
          :maxlength="500"
        />
      </el-form-item>
      <el-form-item>
        <div class="btn-group">
          <el-button type="primary" @click="onSubmit">创建项目</el-button>
          <el-button @click="router.back()">返回</el-button>
        </div>
      </el-form-item>
    </el-form>
  </div>
</template>

<style scoped lang="scss">
.create-project {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  .project-title {
    margin-top: 100px;
    font-size: 20px;
  }

  .create-project-form {
    width: 800px;
    margin-top: 20px;
  }

  .btn-group {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
  }
}
</style>
